/**
 * Project Name:springBoot-serviceImpl
 * File Name:SendServiceImpl.java
 * Package Name:com.libra.rabbitmq.serviceImp
 * Date:2018年8月17日下午4:48:27
 * Copyright (c) 2018, wangzhch All Rights Reserved.
 *
*/

package com.libra.rabbitmq.hello.serviceImp;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.libra.model.mq.Teacher;
import com.libra.rabbitmq.config.QueueConstants;

/**
 * ClassName:一个或多个在同一个队列里面取值 <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason:	 TODO ADD REASON. <br/>
 * Date:     2018年8月17日 下午4:48:27 <br/>
 * @author   wangzhch
 * @version  
 * @since    JDK 1.8
 * @see 	 
 */
@Configuration
public class SendServiceImpl {
	 static Logger logger = LoggerFactory.getLogger(SendServiceImpl.class);
	@Autowired
    private RabbitTemplate rabbitTemplate;

	public void oneToOne(Teacher teacher) {
        logger.info("oneToOne写入消息队列内容：{}", JSON.toJSONString(teacher));
        rabbitTemplate.convertAndSend(QueueConstants.MESSAGE_QUEUE_NAME,teacher);
    }

	public void oneToMany(Teacher teacher ) {
		logger.info("oneToMany写入消息队列内容：{}", JSON.toJSONString(teacher));
        rabbitTemplate.convertAndSend(QueueConstants.MESSAGE_QUEUE_NAME, teacher);
	}

	public void manyToMany(Teacher teacher) {
		logger.info("manyToMany写入消息内容:{}", JSON.toJSONString(teacher));
		rabbitTemplate.convertAndSend(QueueConstants.MESSAGE_QUEUE_NAME,teacher);
	}
	
}

